from flask import Blueprint, render_template, request
from APP.rate_limit import limiter_webcrt

web_crt_pb = Blueprint(
    'web_crt_pb',
    __name__,
    url_prefix='/features'
)

@web_crt_pb.route('/')
@limiter_webcrt.limit('20/day')
def index():
    return render_template('webdriver.html')


@web_crt_pb.route('/ajax',methods=['POST'])
def ajax():
    userAgent = request.form['userAgent']
    platform = request.form['platform']
    hardwareConcurrency = int(request.form['hardwareConcurrency'])
    cookieEabled = request.form['cookieEabled']


    if 'Splash' in userAgent or 'HeadlessChrome' in userAgent:
        return 'False'
    if platform == None:
        return 'False'
    if hardwareConcurrency<2:
        print('核心数小于5')
        return 'False'
    if cookieEabled == 'false':
        return 'False'

    return 'True'